import type { IFormItem } from '@/components/NFormBuilder/types'
import type { TreeSelectOption } from 'naive-ui'
import type { CreateFormItemsOptions } from '@/types/fcform'
import { ScConstants } from '@/components/NFormBuilder/unit/ScConstants'

export const createItems = (options: CreateFormItemsOptions): IFormItem[] => {
  const treeOptions = computed<TreeSelectOption[]>(() => {
    return [
      {
        id: '0',
        name: '根部门',
        children: options.tableData as unknown as TreeSelectOption[],
      },
    ]
  })
  const sc = new ScConstants(24)
  return [
    sc.tree('上级id', 'parentId', {
      options: treeOptions,
    }),
    sc.input('部门名称', 'name'),
    sc.number('部门排序', 'sortOrder'),
  ]
}
